﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Baimasoft.FrameWork.Base;
using Baimasoft.Web.UI;
using HsTec.Mobile.Green.SqlServerDAL;

public partial class DocumentManage_Document_Trad :Baimasoft .Web .UI .PageFormTop
{
    DataFile datafile = new DataFile();

    #region 重写方法

    /// <summary>
    /// 初始化表单信息
    /// </summary>
    protected override void InitForm()
    {
        if (!Page.IsPostBack)
        {

            this.txtTradDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
        }

        if (this.EditStatus == EditStatus.Add)
        {
            //this.EditItemData = new DataFileInfo();
        }
        else if (this.Request.Params["ID"] != null)
        {

            string sID = this.Request.Params["ID"].ToString().Trim();
            SqlDataReader MyDR = datafile.ReadInfo ("a.ID='" + sID + "'");
            if (MyDR.Read())
            {
                this.ddlStatus.SelectedValue = MyDR["Status"].ToString().Trim(); //区域ID

                this.txtName.Text = MyDR["Name"].ToString().Trim(); //资料名称

                this.txtFolderID.Text = MyDR["FolderPath"].ToString().Trim();//所属目录
                this.txtCreatRole.Text = MyDR["CreatRole"].ToString().Trim();//创建人
                this.txtCreatDT.Text = MyDR["FileCreatDT"].ToString().Trim(); //创建时间

                this.txtTrador.Text = Session["Baimasoft_Pers_Name"].ToString();//Trador
                this.Trador.Value = Session["Baimasoft_Pers_ID"].ToString();
                this.txtTradDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
                this.txtTradIdea.Text = MyDR["TradIdea"].ToString().Trim(); 
            }
   
        }
    }
    #endregion
    protected void SaveInfo_Click(object sender, EventArgs e)
    {
        string sID = "";
        if (this.Request.Params["ID"] != null)
        {
            sID = this.Request.Params["ID"].Trim();
        }
        else
        {
            sID = "-1";
        }

        //DataFolder datafolder = new DataFolder();
        //SqlDataReader MyDR = datafolder.GetDataReader("id=" + sid);

        //string sid = "";

        string sddlStatus = ddlStatus.SelectedValue.ToString().Trim();
        string sTrador = Trador.Value.ToString().Trim();
        string sTradDate = txtTradDate.Text.ToString().Trim();
        string sTradIdea = txtTradIdea.Text.ToString().Trim();
        int iback = datafile.UpdateInfo(sddlStatus, sTrador, sTradDate, sTradIdea, sID);
        if (iback > 0)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存成功！');window.close();</script>");
            return;
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存失败！');window.close();</script>");
            return;
        }
    }
}




